using UnityEditor;
using UnityEngine;

namespace Yoozoo.Gameplay.CityEditor
{
    [CustomEditor(typeof(City.CityFogAreaEditor))]
    public class CityFogAreaEditorEditor : UnityEditor.Editor
    {
        private City.CityFogAreaEditor _cityFogAreaEditor;

        private void OnEnable()
        {
            _cityFogAreaEditor = target as City.CityFogAreaEditor;
        }

        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUILayout.Space(20);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("开始编辑", GUILayout.Height(30f)))
            {
                _cityFogAreaEditor.Begin();
            }

            if (GUILayout.Button("结束编辑", GUILayout.Height(30f)))
            {
                _cityFogAreaEditor.End();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("显示标签", GUILayout.Height(30f)))
            {
                _cityFogAreaEditor.BuildLabel();
            }

            if (GUILayout.Button("隐藏标签", GUILayout.Height(30f)))
            {
                _cityFogAreaEditor.DestroyLabel();
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("删除当前区域", GUILayout.Height(30f)))
            {
                bool isOk = EditorUtility.DisplayDialog("警告", $"当前区域为{_cityFogAreaEditor.currentAreaId}\n真的要把当前区域清空么?", 
                    "没错", "我再想想");
                if(isOk)
                    _cityFogAreaEditor.DeleteCurrentArea();
            }
            
            GUILayout.EndHorizontal();
        }
    }
}
